function[out]=setFBS(FBSnum,MBSinfo,PBSinfo)
global  mR fR;
      distance_p=ones(size(PBSinfo));
       while ~isempty(find(distance_p<48));
       r1=mR*sqrt(0.1 + ((0.9-(fR/mR))-0.1).*rand); % the distance from the MBS to the center of the user cluster, '0.8' here is to make sure that every cluster (whose radius is 20m) is located within the macrocell
       seta1=2*pi*rand; % generate a  for the user cluster randomly
       x1=r1.*cos(seta1); % x location for the user cluster
       y1=r1.*sin(seta1); % y location for the user cluster
       distance_p=sqrt((x1-PBSinfo(:,1)).^2+(y1-PBSinfo(:,2)).^2);
%        a=isempty(find(distance_p)<48);
       end
          FBSinfo1(1,:)=[x1,y1];
    
       % generate the user cluster one by one and make sure the distance between two FAPs is larger than 15m
       OF=1; % the number of how many user clusters is generated until now
       CF=1; % the flag to show if the uster cluster satisfys the condition that the distances form it to any other already generated uster clusters is larger than 15m
       while OF<FBSnum
           r=mR*sqrt(0.1 + ((0.9-(fR/mR))-0.1).*rand);
           seta=2*pi*rand; 
           x=r.*cos(seta); 
           y=r.*sin(seta); 
           for i=1:size(FBSinfo1,1)
               distance_f=sqrt((x-FBSinfo1(i,1))^2+(y-FBSinfo1(i,2))^2);
               distance_p=sqrt((x-PBSinfo(:,1)).^2+(y-PBSinfo(:,2)).^2);
               a=isempty(find(distance_p<70));
%                distance_m=sqrt((x-MBSinfo(1,1))^2+(y-MBSinfo(1,2))^2);
                if (~a)||(distance_f<40)
                    CF=2;
                end
           end
           if CF==1;
            FBSinfo1(size(FBSinfo1,1)+1,1)=x;
            FBSinfo1(size(FBSinfo1,1),2)=y;
            OF=OF+1;
           end
         CF=1;
       end
       out=FBSinfo1;
end

